<?

if ($c = stack('name')) {

	$_id_component	= $DATA['components'][$c]['id'];			//	list id value
	$_id_data		= D_MB_DATA;			//	meta id value
	$_id_meta		= D_MB_META;			//	meta id value
	
	$_crit = "id_data=$_id_data AND id_parent=$_id_component";


	$s = array_extend( array(
		'path' => 'catalog', 'w' => 128, 'h' => 96, 'param' => 'id', 'caption' => '', 'lw' => 400, 'lh' => 300,
		'gal_path' => 'catalog/gal', 'gal_tn' => FP_TN_DIR, 'gal_w' => 800, 'gal_h' => 600, 'gal_tnw' => 128, 'gal_tnh' => 96
	), component_settings($c));
	
	$s['h'] = (int)$s['h'];
	$s['w'] = (int)$s['w'];
	$s['gal_w'] = (int)$s['gal_w'];
	$s['gal_h'] = (int)$s['gal_h'];
	$s['gal_tnw'] = (int)$s['gal_tnw'];
	$s['gal_tnh'] = (int)$s['gal_tnh'];


	$a = param($s['param']);

	if ( $temp = datafetch('db_item', tb('data'), "$_crit AND id=$a")) {

		$DATA['components'][$c]['data'] = array_merge($temp, datafetch_array('meta', $_id_meta, $a, $CONTEXT['lang']));
		
		$DATA['components'][$c]['data']['image'] = checkImage(FP_UPLOAD_PATH.$s['path'], "$a-large");

		if (sizeof($DATA['components'][$c]['data']['gallery'] = datafetch_array('gallery2', FP_UPLOAD_PATH."$s[gal_path]-$a/")))
		
			foreach($DATA['components'][$c]['data']['gallery'] as $id => $v) {
				$DATA['components'][$c]['data']['gallery'][$id]['fn'] = FP_UPLOAD_PATH."$s[gal_path]-$a/".$v['fn'];
				$DATA['components'][$c]['data']['gallery'][$id]['tn'] = FP_UPLOAD_PATH."$s[gal_path]-$a/".$v['tn'];
			}
		

		// fix crumbs
		$temp = end(array_keys($DATA['crumb']));
		$DATA['crumb'][$temp] = array('name' => str_cut_long($DATA['components'][$c]['data']['title'], 30, '...'), 'last' => 1);
		
	} else {
		
		header("HTTP/1.0 404 Not Found\n");
		header("Location: "._transformURL($CURRENT->url, array('remove_param' => $s['param'])));
	}

	unstack();
}

?>